package com.anyou.mall.pla.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.mall.pla.domain.PlatformNotice;
import com.anyou.mall.pla.service.IPlatformNoticeService;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * 发布平台通知Controller
 *
 * @author gaochaohao
 * @date 2022-03-21
 */
@Api(tags = "发布平台通知")
@RestController
@RequestMapping("/pla/platformNotice")
public class PlatformNoticeController extends BaseController
{
    @Autowired
    private IPlatformNoticeService platformNoticeService;

    /**
     * 查询发布平台通知列表
     */
    @ApiOperation("查询发布平台通知列表")
    @PreAuthorize("@ss.hasPermi('pla:platformNotice:list')")
    @GetMapping("/list")
    public TableDataInfo<List<PlatformNotice>> list(PlatformNotice platformNotice)
    {
        startPage();
        List<PlatformNotice> list = platformNoticeService.selectPlatformNoticeList(platformNotice);
        return getDataTable(list);
    }

    /**
     * 导出发布平台通知列表
     */
    @ApiOperation("导出发布平台通知列表")
    @PreAuthorize("@ss.hasPermi('pla:platformNotice:export')")
    @Log(title = "发布平台通知", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlatformNotice platformNotice)
    {
        List<PlatformNotice> list = platformNoticeService.selectPlatformNoticeList(platformNotice);
        ExcelUtil<PlatformNotice> util = new ExcelUtil<PlatformNotice>(PlatformNotice.class);
        util.exportExcel(response, list, "发布平台通知数据");
    }

    /**
     * 获取发布平台通知详细信息
     */
    @ApiOperation("获取发布平台通知详细信息")
    @PreAuthorize("@ss.hasPermi('pla:platformNotice:query')")
    @GetMapping(value = "/{platformNoticeId}")
    public ApiResult<PlatformNotice> getInfo(@PathVariable("platformNoticeId") Long platformNoticeId)
    {
        return ApiResult.success(platformNoticeService.selectPlatformNoticeByPlatformNoticeId(platformNoticeId));
    }

    /**
     * 新增发布平台通知
     */
    @ApiOperation("新增发布平台通知")
    @PreAuthorize("@ss.hasPermi('pla:platformNotice:add')")
    @Log(title = "发布平台通知", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody PlatformNotice platformNotice)
    {
        return ApiResult.success(platformNoticeService.insertPlatformNotice(platformNotice));
    }

    /**
     * 修改发布平台通知
     */
    @ApiOperation("修改发布平台通知")
    @PreAuthorize("@ss.hasPermi('pla:platformNotice:edit')")
    @Log(title = "发布平台通知", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody PlatformNotice platformNotice)
    {
        return ApiResult.success(platformNoticeService.updatePlatformNotice(platformNotice));
    }

    /**
     * 删除发布平台通知
     */
    @ApiOperation("删除发布平台通知")
    @PreAuthorize("@ss.hasPermi('pla:platformNotice:remove')")
    @Log(title = "发布平台通知", businessType = BusinessType.DELETE)
    @DeleteMapping("/{platformNoticeIds}")
    public ApiResult remove(@PathVariable Long[] platformNoticeIds)
    {
        return ApiResult.success(platformNoticeService.deletePlatformNoticeByPlatformNoticeIds(platformNoticeIds));
    }

    /**
     * 撤回发布平台通知
     */
    @ApiOperation("撤回发布平台通知")
    @PreAuthorize("@ss.hasPermi('pla:platformNotice:withdraw')")
    @GetMapping("/withdraw/{platformNoticeId}")
    public ApiResult withdraw(@PathVariable Long platformNoticeId) {
        return platformNoticeService.withdrawPlatformNotice(platformNoticeId);
    }

}
